<template>
  <div class="left-bottom-button" @click="click">
    <transition name="el-zoom-in-top">
      <el-tooltip v-show="showMore" class="item" effect="dark" content="目录" placement="top">
        <el-button @click="getContent" type="primary" icon="el-icon-s-fold" class="left-main"></el-button>
      </el-tooltip>
    </transition>
    <transition name="el-zoom-in-top">
      <el-tooltip v-show="showMore" class="item" effect="dark" content="编辑这篇文章" placement="top">
        <el-button type="primary" icon="el-icon-edit" class="left-main" @click="toEdit"> </el-button>
      </el-tooltip>
    </transition>
    <transition name="el-zoom-in-top">
      <el-tooltip v-show="showMore" class="item" effect="dark" content="新增一篇文章" placement="top">
        <el-button type="primary" icon="el-icon-plus" class="left-main" @click="toCreate" style="font-size: 23px"></el-button>
      </el-tooltip>
    </transition>
    <transition name="el-zoom-in-top">
      <el-tooltip v-show="showMore" v-if="type==='check'" class="item" effect="dark" content="本地打开" placement="top">
        <el-button type="warning" icon="el-icon-folder" class="left-main" @click="openMd" style="font-size: 23px"></el-button>
      </el-tooltip>
    </transition>
<!--开始时的展示-->
    <el-tooltip v-show="!showMore" class="item" effect="dark" content="打开工具栏" placement="top">
      <el-button v-show="!showMore" type="primary" icon="el-icon-more" class="left-main"></el-button>
    </el-tooltip>
    <el-tooltip v-show="showMore" class="item" effect="dark" content="收起工具栏" placement="top">
      <el-button v-show="showMore" type="success" icon="el-icon-more" class="left-main"></el-button>
    </el-tooltip>
  </div>
</template>

<script>
import urls from "@/http/urls";
import {openMdFileLocal} from "@/api/article";

export default {
  name: "floatWindow",
  // id 记录当前文章的id号
  // type 表示悬浮窗模式
  props:['id','type'],
  data:function() {
return {
    showMore:false,
  };
},
  methods:{
    click(){
      this.showMore=!this.showMore
    },
    toEdit(){
      window.open(urls.controlPart.editArticle+'?articleId='+this.id,'_blank')
    },
    toCreate(){
      window.open(urls.controlPart.editArticle,'_blank')
    },
    getContent(){
      this.$emit('getContent')
    },
    openMd(){
      openMdFileLocal(this.id).then(()=>{
        this.$message.success("打开成功！");
      })
    }
  }
}
</script>

<style scoped>
.left-bottom-button {
  position: fixed;
  bottom:100px;
  right: 100px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  z-index: 8888;
}
.left-bottom-button .left-main {
  display: inline-flex;
  flex-direction: row;
  justify-content: center;
  border-radius: 50%;
  font-size: 19px;
  height: 50px;
  width: 50px;
  -moz-border-radius: 50%;
  -webkit-border-radius: 50%;
  margin-bottom: 16px;
  margin-left: 20px !important;
}
</style>
